import RequestUtils from '@/utils/RequestUtils'

export default {
  /**
   * 保存订单
   * @param params
   * @returns {AxiosPromise}
   */
  add(params = {}) {
    return RequestUtils({
      url: `/order/salesOrder`,
      method: 'POST',
      data: {
        ...params
      }
    })
  },
  myOrderPage(params = {}, page) {
    return RequestUtils({
      url: `/order/salesOrder/search/myOrder/${page.current}/${page.pageSize}`,
      method: 'POST',
      data: {
        ...params
      }
    })
  },
  /**
   * 批量删除（多个用逗号隔开）
   * @param ids
   * @returns {AxiosPromise}
   */
  remove(ids) {
    return RequestUtils({
      url: `/order/salesOrder/${ids}`,
      method: 'DELETE'
    })
  },
  /**
   * 修改
   * @param params
   * @returns {AxiosPromise}
   */
  edit(params = {}) {
    return RequestUtils({
      url: `/order/salesOrder/${params.id}`,
      method: 'PUT',
      data: {
        ...params
      }
    })
  },
  /**
   * 保存订单
   * @param params
   * @returns {AxiosPromise}
   */
  save(params = {}) {
    return RequestUtils({
      url: `/order/salesOrder/save`,
      method: 'PUT',
      data: {
        ...params
      }
    })
  },
  /**
   * 提交订单
   * @param params
   * @returns {AxiosPromise}
   */
  submit(params = {}) {
    return RequestUtils({
      url: `/order/salesOrder/submit`,
      method: 'PUT',
      data: {
        ...params
      }
    })
  },
  /**
   * 审核保存
   * @param params
   * @returns {AxiosPromise}
   */
  auditSave(params = {}) {
    return RequestUtils({
      url: `/order/salesOrder/auditSave`,
      method: 'PUT',
      data: {
        ...params
      }
    })
  },
  /**
   * 详情
   * @param id
   * @returns {AxiosPromise}
   */
  get(id) {
    return RequestUtils({
      url: `/order/salesOrder/${id}`,
      method: 'GET'
    })
  },
  /**
   * 根据流程实例获取详情
   * @param id
   * @returns {AxiosPromise}
   */
  getBySalesOrderNo(salesOrderNo) {
    return RequestUtils({
      url: `/order/salesOrder/findBySalesOrderNo/${salesOrderNo}`,
      method: 'GET'
    })
  },
  /**
   * 根据流程实例获取详情
   * @param id
   * @returns {AxiosPromise}
   */
  getByProcInsId(procInsId) {
    return RequestUtils({
      url: `/order/salesOrder/findByProcInsId/${procInsId}`,
      method: 'GET'
    })
  },
  /**
   * 列表
   * @param params
   * @returns {AxiosPromise}
   */
  list(params = {}) {
    return RequestUtils({
      url: `/order/salesOrder/search`,
      method: 'POST',
      data: {
        ...params
      }
    })
  },
  /**
   * 列表-分页
   * @param params
   * @returns {AxiosPromise}
   */
  page(params = {}, page) {
    return RequestUtils({
      url: `/order/salesOrder/search/${page.current}/${page.pageSize}`,
      method: 'POST',
      data: {
        ...params
      }
    })
  },
  /**
   * 待审核任务列表
   * @param params
   * @returns {AxiosPromise}
   */
  auditingList() {
    return RequestUtils({
      url: `/order/salesOrder/search/auditingList`,
      method: 'POST'
    })
  },
  /**
   * 已审核任务列表-分页
   * @param params
   * @returns {AxiosPromise}
   */
  auditedList(params = {}, page) {
    return RequestUtils({
      url: `/order/salesOrder/search/auditedList/${page.current}/${page.pageSize}`,
      method: 'POST'
    })
  },
  /**
   * 导出
   * @param params
   * @returns {AxiosPromise}
   */
  exportData(params = {}) {
    return RequestUtils({
      url: `/order/salesOrder/exportData`,
      method: 'POST',
      data: {
        ...params
      }
    })
  },
  /**
   * 下载提案/报价
   * @param id
   * @returns {AxiosPromise}
   */
  downloadQuote(id) {
    return RequestUtils({
      url: `/order/salesOrder/downloadQuote/${id}`,
      method: 'GET'
    })
  },
  /**
   * 确认提案
   * @param params
   * @returns {AxiosPromise}
   */
  confirmQuote(id) {
    return RequestUtils({
      url: `/order/salesOrder/confirmQuote/${id}`,
      method: 'PUT'
    })
  },  
  /**
   * 签订合同
   * @param params
   * @returns {AxiosPromise}
   */
  signContract(params = {}) {
    return RequestUtils({
      url: `/order/salesOrder/signContract`,
      method: 'PUT',
      data: {
        ...params
      }
    })
  },
  /**
   * 确认支付
   * @param params
   * @returns {AxiosPromise}
   */
  confirmPay(params = {}) {
    return RequestUtils({
      url: `/order/salesOrder/confirmPay`,
      method: 'PUT',
      data: {
        ...params
      }
    })
  },
  
  confirmPurchase(params = {}) {
    return RequestUtils({
      url: `/order/salesOrder/confirmPurchase`,
      method: 'POST',
      data: {
        ...params
      }
    })
  },
  /**
   * 发货计划
   * @param params
   * @returns {AxiosPromise}
   */
  deliveryPlan(params = {}) {
    return RequestUtils({
      url: `/order/salesOrder/deliveryPlan`,
      method: 'PUT',
      data: {
        ...params
      }
    })
  },
  importTemplate() {
    return RequestUtils({
      url: `/order/salesOrderItem/importTemplate`,
      method: 'POST'
    })
  },
  /**
   * 确认发货
   * @param params
   * @returns {AxiosPromise}
   */
  delivery(params = {}) {
    return RequestUtils({
      url: `/order/salesOrder/delivery`,
      method: 'PUT',
      data: {
        ...params
      }
    })
  }
}
